﻿using System.Xml.Linq;
using FreeGoo.GameEngine;
using FreeGoo.GameEngine.Renderables;

namespace FreeGoo.LevelClasses.LevelParts
{
    public class BodyHookLevelPart : RenderableLevelPart
    {
        public override string Name { get { return "BodyHook"; } }

        public override Renderable BuildRenderable(Level level, XElement element)
        {
            BodyRenderable body = level.Engine.GetRenderableById(element.Attribute("AttachedTo").Value) as BodyRenderable;

            return MixedFactory.CreateBodyHook(
                level.Engine, 
                body, 
                GetOffsetPosition(level, element),
                element.Attribute("Radius").ToFloat(6));
        }
    }
}
